<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>全部业务历史数据列表</title>
    <s:head/>
</head>
<script type="text/javascript">
    var formSetting = {
        title: "全部业务历史数据列表查询",
        module: 'query',
        columns: [{
            name: "businessId",
            label: "业务编号"
        }/*, {
         name : "type",
         label : "业务类型",
         type : "dropdown",
         data : [ [ "报关", "D" ], [ "拖车", "C" ], [ "货代", "F" ] ]
         }, {
         name : "shipCompany.id",
         label : "大船公司",
         type:"dropdown",
         dropdownType:"ajax",
         url:"../base/dropdown-shipCom",
         minLength:1,
         validate : 'validate[required]'
         } , {
         name : "use_state",
         label : "使用状态",
         type : "dropdown",
         data : [ [ "启用", "0" ], [ "未启用", "1" ] ]
         } */],
        buttons: {
            'custom': [
                {
                    id: "query", value: "获取数据", click: function () {
                    var selectedRowId = $("#ctQueryInfosDataGrid").getGridParam("selrow");
                    if (selectedRowId) {
                        var selectedRow = $("#ctQueryInfosDataGrid").getRowData(selectedRowId);
                        parent.loadBizFromHistoryData(selectedRow.busiId, "all");
                        jw.close();
                    }
                    else {
                        jw.alert("请点击需要操作的数据!");
                    }
                }
                }
            ]
        },
        grid: {
            id: "ctQueryInfosDataGrid",
            title: "查询结果",
            autowidth: false,
            url: "business-findBaseBusinessInfo?loadPage={$'loadPage'}",
            /* postData : {
             "pid" : pid
             }, */
            colModel: [{
                index: "id",
                name: "id",
                hidden: true
            }, {
                index: "busiId",
                name: "busiId",
                label: "业务编号"
            }, {
                index: "customerName",
                name: "customerName",
                label: "真实托运方公司"
            }, {
                index: "bookState",
                name: "bookState",
                label: "订舱状态"
            }, {
                index: "trailState",
                name: "trailState",
                label: "托运状态"
            }, {
                index: "declareState",
                name: "declareState",
                label: "报关状态"
            }, {
                index: "ctime",
                name: "ctime",
                label: "业务时间",
                formatter: 'date',
                formatoptions: {srcformat: 'Y-m-d H:i:s', newformat: 'Y-m-d H:i:s'}
            }],
            jsonReader: {
                userdata: "msg",
                root: "busiDtos"
            },
            gridComplete: function () {
                var msg = $("#ctQueryInfosDataGrid").jqGrid('getGridParam', 'userData');
                if (typeof msg == "string") {
                    jw.alert(msg);
                }
            },
            loadComplete: function (data) {
                var ids = $("#ctQueryInfosDataGrid").getDataIDs();
                for (var i = 0; i < ids.length; i++) {
                    var arrayData = $("#ctQueryInfosDataGrid").getRowData(ids[i]);
                    $("#ctQueryInfosDataGrid").setCell(ids[i], "bookState", "<span style='cursor:pointer;' onclick=\"showState(\'" + ids[i] + "\', 'bookState', \'" + arrayData.busiId + "\', 1);\"><font color='red'>" + $("#ctQueryInfosDataGrid").getCell(ids[i], 3) + "</font><span>");
                    $("#ctQueryInfosDataGrid").setCell(ids[i], "trailState", "<span style='cursor:pointer;' onclick=\"showState(\'" + ids[i] + "\', 'trailState', \'" + arrayData.busiId + "\', 2);\"><font color='red'>" + $("#ctQueryInfosDataGrid").getCell(ids[i], 4) + "</font><span>");
                    $("#ctQueryInfosDataGrid").setCell(ids[i], "declareState", "<span style='cursor:pointer;' onclick=\"showState(\'" + ids[i] + "\', 'declareState', \'" + arrayData.busiId + "\', 3);\"><font color='red'>" + $("#ctQueryInfosDataGrid").getCell(ids[i], 5) + "</font><span>");
                }
            }
        }
    };
    $(document).ready(function () {
        $("#businessDataTable").mrdForm(formSetting);
    });
    //点击显示详细信息
    function showState(trId, symbol, busiId, type) {
        $.post(
                "business-findState",
                {busiId: busiId, type: type},
                function (data) {
                    var s = data.state;
                    if (!s) {
                        s = "没有相关业务信息";
                    }
                    $("#ctQueryInfosDataGrid").setCell(trId, symbol, s);
                }
        );
    }
</script>
</head>
<body>
<div id="businessDataTable"></div>
</body>
</html>
